import { createApp } from 'vue';
import ConfirmDeletion from './ConfirmDeletion.vue';
import ArcoVue from '@arco-design/web-vue';

export default (options = {}) => {
	return new Promise((resolve, reject) => {
		const { keyword = '删除', tipsText, text, okText } = options;
		const container = document.createElement('div');
		const vm = createApp(ConfirmDeletion, {
			keyword,
			tipsText,
			text,
			okText,
			resolve,
			reject,
			remove() {
				vm.unmount();
				document.body.removeChild(container);
			},
		});
		vm.use(ArcoVue).mount(container);
		document.body.appendChild(container);
	});
};
